// vim:set tabstop=4 shiftwidth=4 softtabstop=4 expandtab foldcolumn=1 foldmethod=marker foldclose=all:
/**
 * Project: 5anet
 * File:    src/com/m5anet/main/Application.java
 *
 * This is the Control Servlet, Extends from ActionServlet.
 *
 * In here, I will extends the ActionServlet, for write myself configuration.
 * so, when we start the servlet, we can add some variable to application.
 * and write some customer taglib, for get those variable in our application
 *
 * Author:      $Author: hylinux $
 * Date:        $Date: 2008-01-23 02:18:46 +0000 (Wed, 23 Jan 2008) $
 * Reversion:   $Rev: 13 $
 * Id:          $Id: Application.java 13 2008-01-23 02:18:46Z hylinux $
 *
 */

package com.m5anet.main;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;


import java.io.IOException;
import java.util.ResourceBundle;
import java.util.MissingResourceException;


public class Application extends HttpServlet {
    /**
     * We just need redefine one method
     */
    public void init(ServletConfig config)
                throws ServletException  {
        String root_url = null;
        String image_url = null;


        try { 
            root_url = bundle.getString("ROOTURL");
        } catch ( MissingResourceException ex ) {
            throw new ServletException("We can not find out the root url");
        }

        try {
            image_url = bundle.getString("IMAGEURL");
        } catch ( MissingResourceException ex ) {
            throw new ServletException("We can not find out the image url");
        }

        ServletContext context = config.getServletContext();

        context.setAttribute("rooturl", root_url);
        context.setAttribute("imageurl", image_url);
    }

    private ResourceBundle bundle = ResourceBundle.getBundle("config");
}

